public class t2 {
    public static int maxSum(int[] nums) {
        if (nums == null || nums.length == 0) {
            return 0;
        }
        int max1 = nums[0];
        int max2 = nums[0];
        for (int i = 1; i < nums.length; i++) {
            max2= Math.max(nums[i], max2+ nums[i]);
            max1 = Math.max(max1, max2);
        }
        return max1;
    }
}